package com.xiao.hao.utils;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;

/**
 * @Desciption:
 * @Author: 郑焱军
 * @Date: 2022/8/17 16:14
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
public class Result<T> implements Serializable {

    private T datas;
    private Integer resp_code;
    private String resp_msg;


    public static <T> Result<T> succeed() {
        return (Result<T>) of("操作成功！！！", 200, "SUCCESS");
    }

    public static <T> Result<T> succeed(String msg) {
        return (Result<T>) of(msg, 200, "SUCCESS");
    }

    public static <T> Result<T> succeed(T model, String msg) {
        return of(model, 200, msg);
    }

    public static <T> Result<T> succeed(T model) {
        return of(model, 200, "SUCCESS");
    }

    public static <T> Result<T> of(T datas, Integer code, String msg) {
        return new Result<>(datas, code, msg);
    }

    public static <T> Result<T> failed(String msg) {
        return of(null, 500, msg);
    }

    public static <T> Result<T> failed(T model, String msg) {
        return of(model, 500, msg);
    }

    public static <T> Result<T> failed(String msg, int resp_code) {
        return of(null, resp_code, msg);
    }


}
